<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
	   	<title>编辑个人资料</title>
	    <link href="/static/weike/css/style.css" rel="stylesheet">
	    <script src="/static/weike/js/style.js"></script>
	    <script src="/static/weike/js/pic_deal.js"></script>
	    <script src="/static/js/jquery.js"></script>
	    <script src="/static/lrz/dist/lrz.bundle.js"></script>
	</head>
	<body class="person_zhibocreate">
		<div class="per_zbcreate">
			<section class="input_file">
				<div>头像</div>
				<input type="file" name="0" accept="image/*" />
				<input type="text" name="headpic" id="themp" style="display:none" value="{$person['headpic']}">
				<canvas class="input_canvas" style="display: none;"></canvas>
				<div><img src="{$person['headpic']}" class="press" id="img" /></div>
			</section>
			<section>
				<p>昵称</p>
				<input  name="nickname" id="nickname" value="{$person['nickname']}" />
			</section>
			<section>
				<p>个人介绍</p>
				<textarea class="textarea" placeholder="从零开始学习美工设计理念。" id="introduce" name="introduce">{$person['introduce']}</textarea>
				<p class="textarea_p">您已填写   <span>0</span>/<span>400</span>  字</p>
			</section>
			<footer>
				<div><input type="checkbox" class="check" checked="checked" /><span>我同意遵循</span><span class="user_http" onclick="javascript:window.location.href='http://mg.bonayiyou.com/index/home/tongyong.html?type=3'">《福乐家微课平台用户协议》</span></div>
				<div>
					<button onclick="window.location.href='http://mg.bonayiyou.com/index/home/person_zhibo.html'">取消更改</button>
					<button class="sure">确认更改</button>
				</div>
			</footer>	
		</div>
		<div class="user_yuedu">
			<header><div class="ben_close" style="display: block;"><span></span></div></header>
			<div id="xieyi">
				<!--此处放置协议内容
					-->
			</div>
		</div>
	</body>
</html>
<script>
   document.getElementById('xieyi').innerHTML = '{$content}';
	var user_http = document.getElementsByClassName("user_http")[0],
		user_yuedu = document.getElementsByClassName("user_yuedu")[0],
		ben_close = document.getElementsByClassName("ben_close")[0];
		user_http.onclick=function(){
			user_yuedu.style.display = "block";
		}
		ben_close.onclick=function(){
			user_yuedu.style.display = "none";
		}
	var sure =document.getElementsByClassName("sure")[0],
		check = document.getElementsByClassName("check")[0];
		sure.onclick=function(){
			if(check.checked==true){
			//上次直播间数据
			var data={};
			data['nickname']=$("#nickname").val();
			data['headpic']	=$("#themp").val();
			data['introduce']=$("#introduce").val();
			var url="/index/home/person_edit";
			$.post(url,data,function(e){
            if(e.code==1)
            {
            	window.location.href="http://mg.bonayiyou.com/index/home/person_zhibo.html";
            }
            else{
            	alert('创建失败,请重新创建');
            }
			},"JSON");

			}
			else{
				alert("请先阅读并同意《玫瑰微课平台用户协议》")
			}
		}

	//移动端上传图片
    $("input[type=file]").change(function () {
        /* 压缩图片 */
        lrz(this.files[0], {
        	quality:1
            //width: 300 //设置压缩参数
        }).then(function (rst) {
            /* 处理成功后执行 */
            rst.formData.append('base64img', rst.base64); // 添加额外参数
            $.ajax({
                url: "/index/home/post_img",
                type: "POST",
                data: rst.formData,
                processData: false,
                contentType: false,
                success: function (data) {
                    $("#themp").attr("value",data);
                    $("#img").attr("value",data);
                }
            });
        }).catch(function (err) {
            /* 处理失败后执行 */
        }).always(function () {
            /* 必然执行 */
        })
    })
	var _textarea = document.getElementsByClassName("textarea")[0],
		_text_span = document.getElementsByClassName("textarea_p")[0].getElementsByTagName("span")[0];
		_textarea.oninput=function(){
			if(this.value.length>4){
				this.value = this.value.substr(0,400);
			}
			_text_span.innerText=this.value.length;
		}
</script>